from datetime import timedelta
from redis import StrictRedis
import logging


# 添加配置信息
class Config(object):
    DEBUG = True

    # 1.数据库配置信息
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:mysql@localhost:3306/information17"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # 2.redis配置信息
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    # 3.session配置
    SECRET_KEY = 'SIFJQIO*(^&8'
    SESSION_TYPE = 'redis'
    SESSION_USE_SIGNER = True
    SESSION_REDIS = StrictRedis(REDIS_HOST,REDIS_PORT)
    PERMANENT_SESSION_LIFETIME = timedelta(days=2)

    # 4.csrf配置,只需导包，CSRFProtect()关联app即可

    # 设置日志级别
    LEVEL_NAME = logging.DEBUG



# 开发阶段配置信息
class DevelopConfig(Config):
    pass

# 生产阶段配置信息
class ProductConfig(Config):
    DEBUG = False
    LEVEL_NAME = logging.ERROR

# 测试阶段配置信息
class TestConfig(Config):
    TESTING = True

# 创建字典对外提供配置信息访问入口
config_dict = {
    'develop':DevelopConfig,
    'product':ProductConfig,
    'test':TestConfig
}



